<template>
    <div class="item-head">
        <div class="left">
            <figure class="user-avatar-wrap">
                <router-link to="#">
                    <!-- 111 -->
                    <img :src="info.user.avatar" alt="" class="user-avatar">
                </router-link>
            </figure>
            <div class="left-right">
                <div class="top">
                    <router-link to="#" class="user-name" :class="{'woman': info.user.sex == '女'}">
                        {{info.user.name}}
                    </router-link>
                    <span>{{info.user.address.province}}</span>

                    <span>{{info.user.address.city}}</span>
                </div>
                <div class="bottom" v-if="info.pet.id">
                    <figure class="pet-avatar-wrap">
                        <router-link to="#">
                            <img :src="info.pet.avatar" alt="" class="pet-avatar">
                        </router-link>
                    </figure>
                    <span class="pet-name">{{ info.pet.name }}</span>
                    <span class="pet-delimiter">|</span>
                    <span class="pet-variety">{{ info.pet.variety }}</span>
                    <span class="pet-sex">
                        <template v-if="info.pet.sex=='母'">
                            <img src="/static/img/pet2.png" alt="">
                        </template>
                        <template v-else>
                            <img src="/static/img/pet1.png" alt="">
                        </template>
                    </span>

                </div>
            </div>
        </div>
        <div class="right">
            <button v-if="info.isFollow" class="followed" @click="changeFollow">已关注</button>
            <button v-else class="no-follow" @click="changeFollow"> + 关注</button>
        </div>
    </div>
</template>

<script>
    export default {
        props: ['info'],
        data () {
            return {
            }
        },

        methods: {
            changeFollow() {
                this.info.isFollow = !this.info.isFollow;
            }
        }
    }
</script>

<style>
    .item-head {
        display: flex;
        justify-content: space-between;
        align-items: center;

        background: #fff;
        padding: 0 15px;
        height: 50px;
    }
    .left {
        display: flex;
        align-items: center;
    }
    .user-avatar-wrap {
        margin: 0 10px 0 0;
        padding: 0;
        position: relative;
        width: 30px;
        height: 30px;
        border: 1px solid #eee;
        border-radius: 50%;
        overflow: hidden;
    }
    .left-right {
        display: flex;
        flex-flow: column nowrap;
        align-items: flex-start;
    }
    .left-right .top {
        font-size: 14px;
        color: #999;
    }
    .left-right .bottom {
        position: relative;
        margin-top: 5px;
        height: 18px;
        line-height: 18px;
        padding: 0 3px 0 25px;
        font-size: 12px;
        border-radius: 15px;
        background: #eee;
        color: #333;
    }

    .user-name {
        position: relative;
        color: #98b5f1;
        margin-right: 5px;
    }
    .user-avatar {
        width: 100%;
    }

    .pet-avatar-wrap {
        display: inline-block;
        position: absolute;
        left: 0;
        margin: 0;
        padding: 0;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        overflow: hidden;
    }
    .pet-avatar {
        width: 100%;
    }
    .pet-delimiter {
        color: #ddd;
        padding: 0 3px;
    }
    .pet-sex img {
        position: relative;
        top: 2px;
        width: 10px;
    }
    .man {
        color: #98b5f1;
    }
    .woman {
        color: #f1989e;
    }

    .right button {
        border: 1px solid #ccc;
        border-radius: 3px;
        background: #fff;
        font-size: 13px;
        width: 60px;
        line-height: 20px;
    }
    .followed {
        color: #ccc;
    }
    .no-follow {
        color: #f44;
    }
</style>